local Launcher = class("Launcher", function()
    return require("ds/DataBase"):new()
end)
 
Launcher.m_NoticeList = {}
Launcher.evtMainUserLauncher = "LauncherMainUserLauncher"

function Launcher:init()
  self:onAddListener()
  
  return true
end

function Launcher:onAddListener()
    tools.Event:attach(ds.Launcher.evtMainUserLauncher, handler(self, self.OnMainUser), "Ds_MainUserLauncher")
end

function Launcher:onRemoveListener()
    tools.Event:removeByEventNameAndObserverName(ds.Launcher.evtMainUserLauncher, "Ds_MainUserLauncher")
end

function Launcher:destroy()
  self:onRemoveListener()
end

function Launcher:getNoticeList()
    return self.m_NoticeList
end

function Launcher:OnMainUser( wSubCmdID , packet )
    print("===Launcher:OnMainUser==wSubCmdID="..wSubCmdID)

    local structName
    if(wSubCmdID == Cmd.SUB_CS_MAIL ) then  -- 此处为公告
        structName = 'CMD_MailInfo'
        local structData = Struct:getInstance():getBodyData(structName)
        local data = Struct:getInstance():readBody(packet, structData)
        table.insert(self.m_NoticeList, data)
    elseif(wSubCmdID == Cmd.SUB_CS_MAIL_RECV_DONE ) then -- 邮件接收成功  --不带结构
        return true 
    else 
        print("==error=Launcher:OnMainUser==structName is nil =") 
    end

  
 --   dispatchEventCustom(ds.Account.evtMainUserLauncher, {wSubCmdID=wSubCmdID, data = data } ) 
end

return Launcher
